package com.space.controller;

import com.space.entity.User;
import com.space.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@Api(tags = "测试接口描述",value = "口描述")
@RestController
@RequestMapping("/demo")
public class DemoController {
    @Autowired
    UserService userService;
    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/test")
    @ApiOperation(value = "测试接口")
    @ApiImplicitParams({@ApiImplicitParam(name = "name",value = "姓名",required = true)})
    public String test(@RequestParam("name") String name){

        return "  hello " + userService.getName(0);
    }
    @PostMapping("/testPost")
    @ApiOperation(value = "测试接口")
    @ApiImplicitParams({@ApiImplicitParam(name = "user",dataTypeClass=User.class ,value = "姓名",dataType ="User" )})
    public User testPost(@RequestBody User user){
user.setName("你好 大猛哥");
        return user;
    }
}
